var dbConfig = require('../util/dbconfig')

//获取德甲积分榜
getTheBundesligaIntegral = (req, res) => {
    var sql = "select * from Bintegrals";
    var sqlArr = [];
    var callBack = (err, conn) => {
        if (err) {
            // console.log('连接出错！')
            console.log(err);
        } else {
            res.send({
                status: 200,
                msg: 'GET请求成功',
                data: conn
            })
        }
    }
    dbConfig.sqlConnect(sql, sqlArr, callBack)
}

//获取英超积分榜
getPremierLeagueIntegral = (req, res) => {
    var sql = "select * from Pintegrals";
    var sqlArr = [];
    var callBack = (err, conn) => {
        if (err) {
            // console.log('连接出错！')
            console.log(err);
        } else {
            res.send({
                status: 200,
                msg: 'GET请求成功',
                data: conn
            })
        }
    }
    dbConfig.sqlConnect(sql, sqlArr, callBack)
}

//获取西甲积分榜
getLaLigaIntegral = (req, res) => {
    var sql = "select * from Lintegrals";
    var sqlArr = [];
    var callBack = (err, conn) => {
        if (err) {
            // console.log('连接出错！')
            console.log(err);
        } else {
            res.send({
                status: 200,
                msg: 'GET请求成功',
                data: conn
            })
        }
    }
    dbConfig.sqlConnect(sql, sqlArr, callBack)
}

//获取意甲积分榜
getSerieAIntegral = (req, res) => {
    var sql = "select * from Sintegrals";
    var sqlArr = [];
    var callBack = (err, conn) => {
        if (err) {
            // console.log('连接出错！')
            console.log(err);
        } else {
            res.send({
                status: 200,
                msg: 'GET请求成功',
                data: conn
            })
        }
    }
    dbConfig.sqlConnect(sql, sqlArr, callBack)
}

//获取法甲积分榜
getFrenchArmourIntegral = (req, res) => {
    var sql = "select * from Fintegrals order by id";
    var sqlArr = [];
    var callBack = (err, conn) => {
        if (err) {
            // console.log('连接出错！')
            console.log(err);
        } else {
            res.send({
                status: 200,
                msg: 'GET请求成功',
                data: conn
            })
        }
    }
    dbConfig.sqlConnect(sql, sqlArr, callBack)
}


module.exports = {
    getTheBundesligaIntegral,
    getPremierLeagueIntegral,
    getLaLigaIntegral,
    getFrenchArmourIntegral,
    getSerieAIntegral
}